/**
 * 从 Blob 对象中下载文件
 * @param file Blob 对象
 * @param fileName 下载的文件名
 * @returns
 */
export const saveBlobFile = async (file: Blob | MediaSource, fileName: string): Promise<boolean> => {
  return new Promise((resolve, reject) => {
    try {
      const href = URL.createObjectURL(file)
      const link = document.createElement('a')
      link.href = href
      link.download = fileName
      link.style.display = 'none'
      document.body.appendChild(link)
      link.click()
      URL.revokeObjectURL(href)
      document.body.removeChild(link)
    } catch (error) {
      reject(error)
    } finally {
      resolve(true)
    }
  })
}